home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 5.00 Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx" Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "comdlg32.ocx" Begin VB.MDIForm frmMain Appearance = 0 'Flat BackColor = &H00404040& Caption = "Text Editor" ClientHeight = 6285 ClientLeft = 165 ClientTop = 450 ClientWidth = 7395 Icon = "frmMain.frx":0000 LinkTopic = "MDIForm1" StartUpPosition = 2 'CenterScreen WindowState = 2 'Maximized Begin MSComctlLib.Toolbar tbFind Align = 1 'Align Top Height = 630 Left = 0 TabIndex = 4 Top = 915 Visible = 0 'False Width = 7395 _ExtentX = 13044 _ExtentY = 1111 ButtonWidth = 609 ButtonHeight = 953 AllowCustomize = 0 'False Appearance = 1 _Version = 393216 Begin VB.CommandButton cmdCancel Caption = "&Cancel" Height = 255 Left = 5880 TabIndex = 7 Top = 120 Width = 855 End Begin VB.CommandButton cmdFindNext Caption = "Find Next" Height = 255 Left = 4800 TabIndex = 6 Top = 120 Width = 975 End Begin VB.TextBox Text1 Height = 285 Left = 0 TabIndex = 0 Text = "Search For What?" Top = 120 Width = 3735 End Begin VB.CommandButton cmdFind Caption = "&Find" Default = -1 'True Enabled = 0 'False Height = 255 Left = 3960 TabIndex = 5 Top = 120 Width = 735 End End Begin VB.PictureBox pctBar1 Align = 1 'Align Top BackColor = &H00FFFFFF& Height = 495 Left = 0 Picture = "frmMain.frx":27A2 ScaleHeight = 435 ScaleWidth = 7335 TabIndex = 3 Top = 420 Width = 7395 Begin VB.Label lblDocName BackStyle = 0 'Transparent Caption = "Document Title" BeginProperty Font Name = "Times New Roman" Size = 26.25 Charset = 0 Weight = 700 Underline = 0 'False Italic = -1 'True Strikethrough = 0 'False EndProperty ForeColor = &H000000FF& Height = 495 Left = 0 TabIndex = 8 Top = -120 Width = 11415 End End Begin MSComctlLib.StatusBar StatusBar1 Align = 2 'Align Bottom Height = 255 Left = 0 TabIndex = 2 Top = 6030 Width = 7395 _ExtentX = 13044 _ExtentY = 450 _Version = 393216 BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} NumPanels = 4 BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} Style = 1 Enabled = 0 'False Object.Width = 1129 MinWidth = 1129 Text = "CAPS" TextSave = "CAPS" EndProperty BeginProperty Panel2 {8E3867AB-8586-11D1-B16A-00C0F0283628} Style = 2 Enabled = 0 'False Object.Width = 1129 MinWidth = 1129 TextSave = "NUM" EndProperty BeginProperty Panel3 {8E3867AB-8586-11D1-B16A-00C0F0283628} Object.Width = 12771 MinWidth = 12771 Text = "Document" TextSave = "Document" EndProperty BeginProperty Panel4 {8E3867AB-8586-11D1-B16A-00C0F0283628} Style = 5 Object.Width = 1482 MinWidth = 1482 Text = "Doc" TextSave = "5:20 PM" EndProperty EndProperty End Begin MSComDlg.CommonDialog dlgCommonDialog Left = 1740 Top = 1320 _ExtentX = 847 _ExtentY = 847 _Version = 393216 End Begin MSComctlLib.ImageList imlToolbarIcons Left = 3000 Top = 1560 _ExtentX = 1005 _ExtentY = 1005 BackColor = -2147483643 ImageWidth = 16 ImageHeight = 16 MaskColor = 12632256 _Version = 393216 BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} NumListImages = 13 BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":7722 Key = "New" EndProperty BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":7834 Key = "Open" EndProperty BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":7946 Key = "Save" EndProperty BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":7A58 Key = "Print" EndProperty BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":7B6A Key = "Cut" EndProperty BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":7C7C Key = "Copy" EndProperty BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":7D8E Key = "Paste" EndProperty BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":7EA0 Key = "Bold" EndProperty BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":7FB2 Key = "Italic" EndProperty BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":80C4 Key = "Underline" EndProperty BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":81D6 Key = "Align Left" EndProperty BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":82E8 Key = "Center" EndProperty BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} Picture = "frmMain.frx":83FA Key = "Align Right" EndProperty EndProperty End Begin MSComctlLib.Toolbar tbToolBar Align = 1 'Align Top Height = 420 Left = 0 TabIndex = 1 Top = 0 Width = 7395 _ExtentX = 13044 _ExtentY = 741 ButtonWidth = 609 ButtonHeight = 582 AllowCustomize = 0 'False Appearance = 1 ImageList = "imlToolbarIcons" _Version = 393216 BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} NumButtons = 11 BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "New" Object.ToolTipText = "New" ImageKey = "New" EndProperty BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Open" Object.ToolTipText = "Open" ImageKey = "Open" EndProperty BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Save" Object.ToolTipText = "Save" ImageKey = "Save" EndProperty BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} Style = 3 EndProperty BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Cut" Object.ToolTipText = "Cut" ImageKey = "Cut" EndProperty BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Copy" Object.ToolTipText = "Copy" ImageKey = "Copy" EndProperty BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Paste" Object.ToolTipText = "Paste" ImageKey = "Paste" EndProperty BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} Style = 3 EndProperty BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Bold" Object.ToolTipText = "Bold" ImageKey = "Bold" EndProperty BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Italic" Object.ToolTipText = "Italic" ImageKey = "Italic" EndProperty BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628} Key = "Underline" Object.ToolTipText = "Underline" ImageKey = "Underline" EndProperty EndProperty End Begin VB.Menu mnuFile Caption = "&File" Begin VB.Menu mnuFileNew Caption = "&New" End Begin VB.Menu mnuFileOpen Caption = "&Open" Shortcut = ^O End Begin VB.Menu mnuFileSeperator1 Caption = "-" End Begin VB.Menu mnuFileSave Caption = "&Save" Enabled = 0 'False End Begin VB.Menu mnuFileSaveAs Caption = "Save &As" End Begin VB.Menu mnuFileSeperator2 Caption = "-" End Begin VB.Menu mnuFilePageSetup Caption = "Page Setup" End Begin VB.Menu mnuFilePrint Caption = "Print" End Begin VB.Menu mnuFileSeperator3 Caption = "-" End Begin VB.Menu mnuFileExit Caption = "&Exit" End Begin VB.Menu mnuRecentFile Caption = "-" Index = 0 Visible = 0 'False End Begin VB.Menu mnuRecentFile Caption = "RecentFile1" Index = 1 Visible = 0 'False End Begin VB.Menu mnuRecentFile Caption = "RecentFile2" Index = 2 Visible = 0 'False End Begin VB.Menu mnuRecentFile Caption = "RecentFile3" Index = 3 Visible = 0 'False End Begin VB.Menu mnuRecentFile Caption = "RecentFile4" Index = 4 Visible = 0 'False End Begin VB.Menu mnuRecentFile Caption = "RecentFile5" Index = 5 Visible = 0 'False End End Begin VB.Menu mnuEdit Caption = "&Edit" Begin VB.Menu mnuEditCut Caption = "C&ut" End Begin VB.Menu mnuEditCopy Caption = "&Copy" End Begin VB.Menu mnuEditPaste Caption = "&Paste" End Begin VB.Menu mnuFileSeperator5 Caption = "-" End Begin VB.Menu mnuEditFind Caption = "&Find" End Begin VB.Menu mnuEditFindNext Caption = "Find &Next" Shortcut = {F3} End Begin VB.Menu mnuFileSeperator6 Caption = "-" End Begin VB.Menu mnuEditTime Caption = "&Time/Date" End Begin VB.Menu mnuEditSelectAll Caption = "&Select All" End End Begin VB.Menu mnuFonts Caption = "F&onts" Begin VB.Menu mnuFontsFont Caption = "&Font" Index = 0 End Begin VB.Menu mnuFontsColor Caption = "&Color" End End Begin VB.Menu mnuView Caption = "&View" Begin VB.Menu mnuViewToolbar Caption = "&Toolbar" Checked = -1 'True End End Begin VB.Menu mnuWindow Caption = "&Window" WindowList = -1 'True Begin VB.Menu mnuWindowArrangeIcons Caption = "Arrange Icons" End Begin VB.Menu mnuWindowTileVertical Caption = "Tile Vertical" End Begin VB.Menu mnuWindowCascade Caption = "Cascade" End Begin VB.Menu mnuWindowTileHorizontal Caption = "Tile Horizontal" End End Begin VB.Menu mnuHelp Caption = "&Help" Begin VB.Menu mnuHelpAbout Caption = "&About" End End Attribute VB_Name = "frmMain" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False 'Some Notes on some of the functions I used: 'ActiveForm: ' The ActiveForm function that I used is used mostly when you are creating a 'MDI Application. I used it on alot of things because I've either forgotten 'Any other way to do it or never knew how to do it any other way. 'Other Notes: 'Im sorry about the mess of the application up to this one. I was using different methods 'Of doing things.. Some harder, some easier/faster. Dim DocChanged2 As Boolean Option Explicit 'This is for the find function Private Sub cmdCancel_Click() tbFind.Visible = False mnuEditFind.Checked = False End Sub 'This is for the find function Private Sub cmdFind_Click() Dim textfound As Integer ' Finds the text in the search box and highlights it, ' then sets the focus on the richtextbox so the selected ' text is editable. ActiveForm.rtfBox1.Find (Text1.Text) 'Sets the window/blinking thing to the rtfBox ActiveForm.rtfBox1.SetFocus ' The ActiveForm.rtfBox1.Find method returns an integer ' value of -1 if the searched for text is not found. ' If this is true then it displays a message box. textfound = ActiveForm.rtfBox1.Find(Text1.Text) If textfound = -1 Then MsgBox "Search finished. No text found!", vbInformation, "No Text Found" End If End Sub 'This routes the FindNext to the menu, that way I dont have to write more lines 'Of code to make it do the exact same thing. Private Sub cmdFindNext_Click() mnuEditFindNext_Click End Sub Private Sub MDIForm_Load() 'This automatically opens a new document when the project loads. LoadNewDoc StatusBar1.Panels(3).Text = ActiveForm.Caption ChDir App.Path lblDocName.Caption = ActiveForm.Caption End Sub Private Sub mnuEditCopy_Click() 'When someone clicks the menu Edit and Copy it will copy the selected text into the clipboard. On Error Resume Next Clipboard.SetText ActiveForm.rtfBox1.SelRTF End Sub Private Sub mnuEditCut_Click() 'When someone click the menu Edit and Cut it will Remove the text from the document and put it on the clipboard. On Error Resume Next Clipboard.SetText ActiveForm.rtfBox1.SelRTF ActiveForm.rtfBox1.SelText = vbNullString End Sub Private Sub mnuEditFind_Click() 'When someone clicks the menu Edit Find this will un hide the ToolBar for the find proc If tbFind.Visible = False Then tbFind.Visible = True mnuEditFind.Checked = True If tbToolBar.Visible = False Then End If ' This routine hides the Find Toolbar. ' And resizes the richtextbox dependin on whether or not the ' standard toolbar is shown. tbFind.Visible = False mnuEditFind.Checked = False If tbToolBar.Visible = False Then End If End If End Sub 'Finds the next word the person has entered in the box. Private Sub mnuEditFindNext_Click() ' Set the focus so the selected text can be directly edited. ActiveForm.rtfBox1.SetFocus ' Finds the next instance of the word, starting from ' the selected text. ActiveForm.rtfBox1.Find (Text1.Text), ActiveForm.rtfBox1.SelStart + 1 End Sub Private Sub mnuEditPaste_Click() 'When someone clicks the menu Edit and Paste it will paste what ever text is on the clipboard into the current open document. On Error Resume Next ActiveForm.rtfBox1.SelRTF = Clipboard.GetText End Sub Private Sub mnuEditSelectAll_Click() 'When someone clicks the menu Edit and Select All it will Select All text in the document. On Error Resume Next ' Use SelStart & SelLength to select the text. ActiveForm.rtfBox1.SelStart = 0 ActiveForm.rtfBox1.SelLength = Len(ActiveForm.rtfBox1.Text) End Sub Private Sub mnuEditTime_Click() On Error Resume Next 'Display current time & Date ActiveForm.rtfBox1.SelRTF = Now End Sub Private Sub mnuFileExit_Click() End End Sub 'Allows the person to save the file they made in either .TXT or .WRI or any other format they want. Private Sub mnuFileSave_Click() ' SaveDoc Dim sFile As String Dim sTitle As String If Left$(ActiveForm.Caption, 8) = "Untitled" Then With dlgCommonDialog .DialogTitle = "Save File" .CancelError = False .FileName = ActiveForm.Caption .Flags = cdlOFNHideReadOnly Or cdlOFNOverwritePrompt .Filter = "Ritch Text Files (*.wri)|*.wri|Text Files (*.txt)|*.txt|All Files (*.*)|*.*" .ShowSave If Len(.FileName) = 0 Then Exit Sub End If sFile = .FileName sTitle = .FileTitle If UCase(Right(ActiveForm.rtfBox1.FileName, 3)) = "WRI" Then ActiveForm.rtfBox1.SaveFile sFile, rtfRTF Else ActiveForm.rtfBox1.SaveFile sFile, rtfText End If DocChanged2 = False End With ActiveForm.Caption = sTitle fMainForm.StatusBar1.Panels(3).Text = "Document: " & sTitle fMainForm.lblDocName.Caption = ActiveForm.Caption ActiveForm.rtfBox1.SaveFile sFile Else ActiveForm.rtfBox1.SaveFile sFile, rtfText End If End Sub 'This is so when they click File and SaveAs it will open a SaveAs dialog box so the text document can be saved into another file. Private Sub mnuFileSaveAs_Click() Dim sFile As String Dim sTitle As String Dim DocChanged DocChanged = False If ActiveForm Is Nothing Then Exit Sub With dlgCommonDialog .DialogTitle = "Save As" .CancelError = False .Filter = "Ritch Text Files (*.wri)|*.wri|Text Files (*.txt)|*.txt|All Files (*.*)|*.*" .Flags = cdlOFNHideReadOnly Or cdlOFNOverwritePrompt .ShowSave If Len(.FileName) = 0 Then Exit Sub End If sFile = .FileName sTitle = .FileTitle If UCase(Right(ActiveForm.rtfBox1.FileName, 3)) = "WRI" Then ActiveForm.rtfBox1.SaveFile sFile, rtfRTF Else ActiveForm.rtfBox1.SaveFile sFile, rtfText End If DocChanged = False End With ActiveForm.Caption = sTitle fMainForm.StatusBar1.Panels(3).Text = "Document: " & sTitle fMainForm.lblDocName.Caption = ActiveForm.Caption End Sub Private Sub mnuFontsColor_Click() ' Shows the color dialog box and sets the current color. dlgCommonDialog.Flags = cdlCCFullOpen dlgCommonDialog.ShowColor ActiveForm.rtfBox1.SelColor = dlgCommonDialog.Color End Sub Private Sub mnuFontsFont_Click(Index As Integer) ' Shows the Font dialogue box and sets the current font. dlgCommonDialog.Flags = cdlCFBoth Or cdlCFEffects dlgCommonDialog.ShowFont With ActiveForm.rtfBox1 .SelFontName = dlgCommonDialog.FontName .SelFontSize = dlgCommonDialog.FontSize .SelBold = dlgCommonDialog.FontBold .SelItalic = dlgCommonDialog.FontItalic .SelStrikeThru = dlgCommonDialog.FontStrikethru .SelUnderline = dlgCommonDialog.FontUnderline .SelColor = dlgCommonDialog.Color End With End Sub 'This is so the user can hide and view the toolbar.. Im thinking of making it so they can customize the toolbar. Private Sub mnuViewToolbar_Click() mnuViewToolbar.Checked = Not mnuViewToolbar.Checked tbToolBar.Visible = mnuViewToolbar.Checked End Sub 'This is for the toolbar so that when someone clicks on the buttons it will do the action. Private Sub tbToolBar_ButtonClick(ByVal Button As MSComctlLib.Button) Select Case Button.Key Case "New" On Error Resume Next LoadNewDoc Case "Open" On Error Resume Next mnuFileOpen_Click Case "Save" On Error Resume Next mnuFileSave_Click Case "Cut" On Error Resume Next mnuEditCut_Click Case "Copy" On Error Resume Next mnuEditCopy_Click Case "Paste" On Error Resume Next mnuEditPaste_Click Case "Bold" On Error Resume Next ActiveForm.rtfBox1.SelBold = Not ActiveForm.rtfBox1.SelBold Button.Value = IIf(ActiveForm.rtfBox1.SelBold, tbrPressed, tbrUnpressed) Case "Italic" On Error Resume Next ActiveForm.rtfBox1.SelItalic = Not ActiveForm.rtfBox1.SelItalic Button.Value = IIf(ActiveForm.rtfBox1.SelItalic, tbrPressed, tbrUnpressed) Case "Underline" On Error Resume Next ActiveForm.rtfBox1.SelUnderline = Not ActiveForm.rtfBox1.SelUnderline Button.Value = IIf(ActiveForm.rtfBox1.SelUnderline, tbrPressed, tbrUnpressed) End Select End Sub 'Private Sub LoadNewDoc() ' Static lDocumentCount As Long ' Dim frmDoc As frmText1 ' lDocumentCount = lDocumentCount + 1 ' Set frmDoc = New frmText1 ' frmDoc.Caption = "TextBox " & lDocumentCount ' frmDoc.Show 'End Sub Private Sub mnuFileOpen_Click() Dim sFile As String Dim sTitle As String ' Dim strOpenFileName As String If ActiveForm Is Nothing Then LoadNewDoc With dlgCommonDialog .DialogTitle = "Open Text Document" .FileName = "" .CancelError = False .Filter = "Text Files (*.txt)|*.txt|Ritch Text Files (*.wri)|*.wri|All Files (*.*)|*.*" .Flags = cdlOFNHideReadOnly Or cdlOFNFileMustExist .ShowOpen ' If the file is larger than 65K, it can't ' be opened, so cancel the operation. ' On Error GoTo DiskErrorHandler If FileLen(.FileName) > 65000 Then MsgBox "The file is too large to open." Exit Sub End If If Len(.FileName) = 0 Then Exit Sub End If ' strOpenFileName = fMainForm.dlgCommonDialog.Filename sFile = .FileName sTitle = .FileTitle End With LoadNewDoc ActiveForm.rtfBox1.LoadFile sFile ActiveForm.Caption = "Open Document - " & sTitle fMainForm.StatusBar1.Panels(3).Text = "Document: " & sTitle fMainForm.lblDocName.Caption = ActiveForm.Caption 'DiskErrorHandler: 'Select Case Err.Number ' Case ErrInvalidFileName, ErrBadFileName ' MsgBox "There was an Error!", vbOKOnly, "Cannot find File" ' Case 53 ' M$ = "The file you specified was not found. Please check your spelling and try again.. Error 53!" ' Case 55 ' M$ = "The file you specified is already open it. Please close it and try again. Error 55!" ' Case Else ' Dim intErrNum As Integer ' intErrNum = Err.Number ' Err.Clear 'Clear the Err oject. ' Err.Raise Number:=intErrNum 'Regenerate the error. ' MsgBox "There was an Error!", vbOKOnly, "Cannot find File" ' End Select ' M$ = M$ + vbCrLf + vbCrLf + "For a Error Number list check the help file. Error Number: " & Err.Number & " has occured " ' M$ = M$ + "" ' WhatToDo% = MsgBox(M$, vbCritical, "Error Number " & Err.Number & " has occured! ") ' If WhatToDo% = vbYes Then End Sub Private Sub mnuFileNew_Click() 'When someone clicks File and New it will create a new document. LoadNewDoc End Sub 'Allows the user to print a document hopefully Private Sub mnuFilePrint_Click() On Error Resume Next If ActiveForm Is Nothing Then Exit Sub With dlgCommonDialog .DialogTitle = "Print - Print Now" .CancelError = True .Flags = cdlPDReturnDC + cdlPDNoPageNums If ActiveForm.rtfBox1.SelLength = 0 Then .Flags = .Flags + cdlPDAllPages Else .Flags = .Flags + cdlPDSelection End If .ShowPrinter If Err <> MSComDlg.cdlCancel Then ActiveForm.rtfBox1.SelPrint .hDC End If End With End Sub Private Sub mnuFilePageSetup_Click() On Error Resume Next With dlgCommonDialog .DialogTitle = "Print - Page Setup" .CancelError = True .ShowPrinter End With End Sub 'Allows user to Arrange the Windows Private Sub mnuWindowArrangeIcons_Click() Me.Arrange vbArrangeIcons End Sub 'Allows user to Arrange the Windows Private Sub mnuWindowTileVertical_Click() Me.Arrange vbTileVertical End Sub 'Allows user to Arrange the Windows Private Sub mnuWindowTileHorizontal_Click() Me.Arrange vbTileHorizontal End Sub 'Allows user to Arrange the Windows Private Sub mnuWindowCascade_Click() Me.Arrange vbCascade End Sub 'This is as a backup just incase one of the forms are still open when the user closes the main window, this will close the entire program to save memory. Private Sub MDIForm_Unload(cancel As Integer) End End Sub Private Sub Text1_Change() ' Enables the find button when the search text is entered. cmdFind.Enabled = True End Sub